//
//  ImgTextFieldView.m
//  02_Homework
//
//  Created by 李昊林 on 16/7/23.
//  Copyright © 2016年 李昊林. All rights reserved.
//

#import "ImgTextFieldView.h"

@implementation ImgTextFieldView


#pragma mark - Init And Create
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        return [self initWithFrame:frame image:nil placeHolder:nil];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image placeHolder:(NSString *)placeHolder {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviewsWithFrame:frame];
        [self config];
        self.imageView.image = image;
        self.textField.placeholder = placeHolder;
    }
    return self;
    
}
#pragma mark - 设置
- (void)config {
    self.imageView.backgroundColor = [UIColor blackColor];
    self.imageView.alpha = 0.4;
    self.textField.backgroundColor = [UIColor blackColor];
    self.textField.alpha = 0.4;
    self.textField.textColor = [UIColor whiteColor];
}
#pragma mark - 规定imageView和textField的大小
- (void)createSubviewsWithFrame:(CGRect)frame {
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.height, frame.size.height)];
    [self addSubview:self.imageView];
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(frame.size.height, 0, frame.size.width - frame.size.height, frame.size.height)];
    [self addSubview:self.textField];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
